include ../config.mk

# require bash for building documentation.html
SHELL = /bin/bash

dist_srcdir = docs
dist_FILES = \
	$(SOURCE_PODS) \
	Makefile.in \
	HOC.html \
	README.txt \
	documentation-footer.template \
	documentation-header.template \
	$(NULL)

TITLE = HOC: a Haskell to Objective-C bridge

SOURCE_PODS = Introduction.pod \
	      Quick_Start.pod \
	      Mapping_Types.pod \
	      Accessing_Other_Frameworks.pod \
	      Creating_an_Objective-C_Class_in_Haskell.pod \
	      Tools.pod \
	      Appendices.pod \
	      $(NULL)

SOURCE_DOTS = \
	      $(NULL)

# ---

SOURCE_PNGS = \
	      $(NULL)

all: HOC.html

%.png: %.dot
	$(DOT) -Tpng

HOC.html: $(SOURCE_PODS) $(SOURCE_PMGS)
	$(POD2HTML) \
	  --index \
	  --header \
	  --title="${TITLE}" \
	  --outfile "$@" \
	  $+

# documentation.html is similar to HOC.html, but without the <body> tags
# (suitable for inclusion into a SSI'ed webpage)

documentation.html: HOC.html
	cat \
	  documentation-header.template \
	  <(sed -e '1,/^<body.*>$$/d' -e '/^<\/body>.*$$/,$$d' < $+) \
	  documentation-footer.template \
	  > $@

view: HOC.html
	open $+

dist: HOC.html

# failed attempt at getting Safari to print to PDF; see
# http://64.233.167.104/search?q=cache:F2D2JTT0b98J:www1.odn.ne.jp/~cge02410/panther/system_events_003.html+applescript+safari+print+pdf&hl=en for more info
# HOC.pdf: HOC.html

install:
	true

clean:
	-rm HOC.html pod2htm* documentation.html

